package com.gitee.mazhenggg.demo.gateway.service;


import com.gitee.mazhenggg.demo.common.constant.UrlConstants;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;

/**
 * @author mazhenggg
 */
@Service
public class AuthService {

    @Autowired
    private WebClient.Builder webclientBuilder;

    public String verifyToken(String header,String token){
        WebClient client=webclientBuilder.build();
        Mono<String> mono = client.get().uri(UrlConstants.VERIFY_URL).header(header,token)
                .accept(MediaType.APPLICATION_JSON).retrieve().bodyToMono(String.class);

        String[] t = new String[1];
        String r =mono.block();
        //System.out.println(r.getBody());
        return r;
    }

}
